/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pa165.dominatingspecies.frontend.security;

import org.apache.wicket.Component;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 *
 * @author Filip Dinh
 */
public class Authorizer {
    
    public static void authorize(Component component){
        boolean enabled = false;
        for(GrantedAuthority authority : SecurityContextHolder.getContext().getAuthentication().getAuthorities()){
            if(authority.getAuthority().equals("ADMIN")){
                enabled = true;
            }
        }
        component.setEnabled(enabled);
        component.setVisible(enabled);
    }
    
}
